package com.ljc.dao;

import com.ljc.entity.Administrator;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

@Mapper
@Repository
public interface AdministratorDao {

    @Select("select id,name,password from administrator where name=#{username}")
    Administrator findByName(String username);

    @Select("insert into administrator(name,password,phone,email,organization) " +
            "values(#{name},#{password},#{phone},#{email},#{organization})")
    void addAdministrator(Administrator administrator);

    @Select("select * from administrator where id=#{id}")
    Administrator selectById(int id);

    @Update("update administrator set name=#{name},phone=#{phone},email=#{email},organization=#{organization}, " +
            "password=#{password}" +
            "where id=#{id}")
    void update(Administrator administrator);

    @Update("update administrator set password=#{password} where id=#{id}")
    void modifyPassword(int id,String password);
}
